package app

import (
	"example.com/go-vue.git/app/admin"
	"example.com/go-vue.git/app/home"
	"example.com/go-vue.git/app/wechat"
	"example.com/go-vue.git/app/wxapp"
	"github.com/gin-gonic/gin"
)

type Option func(*gin.Engine)

var options = []Option{}

/*注册app的路由配置*/
func Include(opts ...Option) {
	options = append(options, opts...)
}

/*注册路由*/
func Register() {
	Include(admin.Routers)
	Include(home.Routers)
	Include(wechat.Routers)
	Include(wxapp.Routers)
}

/*初始化了路由*/
func Init() *gin.Engine {
	Register()
	r := gin.New()
	for _, opt := range options {
		opt(r)
	}
	// 前端vue项目
	// r.LoadHTMLGlob("view/vue/dist/*.html")
	// r.Static("/static", "./view/vue/dist/static")
	// r.StaticFile("/", "view/vue/dist/index.html")
	return r
}
